package com.gmzg.gmzgnews.topic.view;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.gmzg.gmzgnews.R;

public class TopicDetailActivity extends AppCompatActivity {

    private WebView mWebView;
    private static final String TAG = "TopicDetailActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //set progress bar in window style
        getWindow().requestFeature(Window.FEATURE_PROGRESS);

        setContentView(R.layout.activity_topic_detail);


        WebView webView = (WebView) findViewById(R.id.topic_detail_web_view);
        WebSettings settings = webView.getSettings();
        settings.setSupportZoom(true);
        settings.setJavaScriptEnabled(true);

        //do not jump to system web view
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });

        webView.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {

            }
        });
        Intent intent = getIntent();
        String url = intent.getStringExtra("url");
        Log.d(TAG, "onCreate: webView中获取的网址：" + url);

        webView.loadUrl(url);
    }
}
